package poliakov.spring.advertisement.mvc;

import java.util.Map;

import javax.inject.Inject;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import poliakov.spring.advertisement.AdvertisementService;

@Controller
public class HomeController {
	public static final int DEFFAULT_ADS_PER_PAGE = 25;
	private AdvertisementService advsrv;
	
	@Inject  
	public HomeController (AdvertisementService advsrv) {
		this.advsrv = advsrv;
	}
	
	@RequestMapping({"/","/home"})
	public String showHomePage(Map <String, Object> model) {
		model.put("advertisements", advsrv.getAllAds());
		return "home";
	}
}
